<template>
	<view>
		<image class="image" :src="imgHost+'/static/images/lingqu.png'" mode="widthFix"></image>
		<view class="get_button" @click="togetFun">领取</view>
	</view>
</template>

<script>
	import { toLogin } from '@/libs/login.js';
	import { mapState, mapGetters } from 'vuex';
	import { HTTP_REQUEST_URL } from '@/config/app';
	import {
		memberCardClaim
	} from '@/api/user.js';
import { node } from '../../../plugin/clipboard/clipboard';
	export default {
		data() {
			return {
				id:'',
				imgHost:HTTP_REQUEST_URL,
			};
		},
		computed: {
			...mapGetters({
				isLogin: 'isLogin'
			})
		},
		onLoad(e) {
			this.id = e.id
		},
		onShow() {
			
		},
		onPageScroll(e) {
			this.scrollY = e.scrollTop;
		},
		//#ifdef MP
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {
			let that = this,
			share = {
				title: '299元健康体验官会员',
				path: '/pages/users/user_vip_gift/get?id=' + that.cardInfo.id,
				imageUrl: that.imgHost+'/static/images/img_jktyg@2x.png'
			};
			return share;
		},
		//#endif
		methods: {
			togetFun(){
				console.log(this.id)
				if (this.isLogin == false) {
					toLogin();
				}else{
					let that = this;
					memberCardClaim({card_id:this.id}).then(res => {
						if(res.status == 400){
							uni.showToast({
								title:res.msg,
								icon: 'none'
							})
						}else{
							uni.showToast({
								title:'领取成功'
							})
							setTimeout(()=>{
								uni.reLaunch({
									url:'/pages/users/user_vip_experience/index'
								})
							},500)
						}
						
					});
				}
			},
		},
		onReachBottom() {
			
		}
	}
</script>

<style>
	.image{
		display: block;
		width: 100%;
	} 
	.get_button{
		position: fixed;
		left: 0;
		right: 0;
		bottom: 80rpx;
		margin: auto;
		width: 630rpx;
		height: 80rpx;
		border-radius: 80rpx;
		background: rgba(0, 179, 239, 1);
		
		display: flex;
		align-items: center;
		justify-content: center;
		
		font-size: 32rpx;
		font-weight: 400;
		color: #FFF;
	}
</style>
